package com.springboot.demo.conf;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@Configuration
@Aspect
public class AOPConfig {

    @Around("@within(org.springframework.web.bind.annotation.RestController) ")
    public Object simpleAop(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
        try{
            Object[] args = proceedingJoinPoint.getArgs();
            System.out.println("args:"+ Arrays.asList());

            //调用原有的方法
            Object o = proceedingJoinPoint.proceed();
            System.out.println("return :"+o );
            return o;
        }catch (Throwable e){
            throw e;
        }
    }
}
